package main;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import conditions.*;

/**
 * handles turns! (big surprise)
 * @author 12817152
 *
 */


public class TurnManager {
	int turn = 0;
	int turnLength = 3; //let's call this no of hours between each turn
	Player p1, p2;
	Player active;
	Player inactive;
	MapPanel mp;
	boolean paused = false;
	boolean techSet = false;
/**
 * base constructor
 * @param player1 Player 1
 * @param player2 Player 2
 * @param map map on which you play
 */
	public TurnManager(Player player1, Player player2, MapPanel map) {
		p1 = player1;
		p2 = player2;
		active = p1;
		inactive = p2;
		mp = map;
	}

	/**
	 * unpause after turn switch
	 */
	public void resume() {
		mp.unblack();
		active.incrementTurn();
		try {
			//System.out.println(active.getRes().getTree().currentTech.Name);
		} catch(NullPointerException e) {
			//System.err.println("don't panic. not an error. [research tech null]");
		}
		turn++;
		paused = false;
	}

	/**
	 * iterate to next turn
	 */
	public void increment() {
		if(active == p1) {
			active = p2;
			inactive = p1;
		}
		else {
			active = p1;
			inactive = p2;
		}
		mp.blackout();
		mp.updatePlayer(active);
		paused = true;
		techSet = false;
	}


	/**
	 * get turn
	 * @return int turn
	 */
	public int getTurn() {
		return turn;
	}

	
}
